import argparse
import os
import logging

def get_env():
    parser = argparse.ArgumentParser()
    parser.add_argument('--env', default=None, help='环境名(test/prod)')
    args, _ = parser.parse_known_args()
    return args.env or os.environ.get('ENV', 'test')

ENV = get_env()
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
CONFIG_PATH = os.path.join(BASE_DIR, 'common', f'config.{ENV}.ini')

# 日志初始化（全局只需调用一次）
def setup_logger():
    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
    logging.info(f"========== 当前环境: {ENV}，配置文件: {CONFIG_PATH} ==========")
